<template>
  <div class="favorite">
    <div class="titledesc">
      <div>
        <el-link type="warning"><span>我的收藏</span></el-link>
        <div class="operation">
          <el-button plain type="success" @click="operate">操作</el-button>
          <el-checkbox label="全选" v-if="chckedShow" v-model="checkedAll" @change="gocheckedAll()" style="margin: 0 10px"></el-checkbox>
          <el-checkbox label="全选" disabled v-else style="margin: 0 10px"></el-checkbox>
          <el-button plain type="danger">删除</el-button>
        </div>
      </div>
    </div>
    <div class="container">
      <div class="goods-detail-item" v-for="(item,index) in favoriteList" :key="index">
        <div class="check" :class="{active:item.checked}" @click="checked(item)" v-show="chckedShow">
          <el-icon style="transform: rotate(58deg);"><Check /></el-icon>
        </div>
        <div class="goods-detail-item-top">
          <img :src="item.imgsrc" alt="图片走丢了">
        </div>
        <!--商品信息-->
        <div class="goods-info">
          <!--              内容，名字-->
          <div class="title">
            <a >
              {{item.desc}}
            </a>
          </div>
          <div class="operate">
            <a >
              取消收藏
            </a>
            <a>
              查看详情
            </a>
          </div>
        </div>
      </div>
      <el-pagination
          style="justify-content: center;margin: 20px 0"
          background
          layout="prev, pager, next"
          :total="50"
          class="mt-4"
      />
    </div>
  </div>
</template>

<script setup>

import {reactive, ref} from "vue";


  let favoriteList = reactive([
    {
      imgsrc:'http://lixinghe.meimeng.eu.org/flower/image/20141006231606_CrJmu.jpeg',
      desc:'真的爱你',
      checked:false
    },
    {
      imgsrc:'http://lixinghe.meimeng.eu.org/flower/image/20141006231606_CrJmu.jpeg',
      desc:'真的爱你',
      checked:false
    },
    {
      imgsrc:'http://lixinghe.meimeng.eu.org/flower/image/20141006231606_CrJmu.jpeg',
      desc:'真的爱你',
      checked:false
    },
    {
      imgsrc:'http://lixinghe.meimeng.eu.org/flower/image/20141006231606_CrJmu.jpeg',
      desc:'真的爱你',
      checked:false
    },
    {
      imgsrc:'http://lixinghe.meimeng.eu.org/flower/image/20141006231606_CrJmu.jpeg',
      desc:'真的爱你',
      checked:false
    },
    {
      imgsrc:'http://lixinghe.meimeng.eu.org/flower/image/20141006231606_CrJmu.jpeg',
      desc:'真的爱你',
      checked:false
    },
    {
      imgsrc:'http://lixinghe.meimeng.eu.org/flower/image/20141006231606_CrJmu.jpeg',
      desc:'真的爱你',
      checked:false
    },
  ])


  const checked = (item) => {
    console.log('我被点击了');
    item.checked = !item.checked
  }
  let chckedShow = ref(false)

  const operate = () => {
    console.log(chckedShow.value);
    chckedShow.value = !chckedShow.value
  }

  let checkedAll = ref(false)

  const gocheckedAll = () => {

    checkedAll = checkedAll !== true;

    for (let favoriteListElement of favoriteList) {
      favoriteListElement.checked = checkedAll
    }
  }

</script>

<style scoped lang="scss">
  .favorite{
    .titledesc {
      border-bottom: 1px solid gainsboro;
      &>div {
        display: flex;
        align-items: center;
        justify-content: space-between;
      }
      span {
        font-size: 20px;
        display: block;
        padding: 10px 0;
      }
      .operation {
        display: flex;
        align-items: center;
        margin-right: 20px;
      }

    }
  }
  .goods-detail-item {
    display: inline-block;
    width: 230px;
    text-align: center;
    height: 320px;
    position: relative;
    overflow: hidden;
    margin: 10px;
    border: 1px solid gainsboro;
    /* box-shadow: 0 4px 8px 0 rgb(0 0 0 / 20%), 0 6px 20px 0 rgb(0 0 0 / 19%); */
    border-radius: 10px;
    &:hover {
      transition: all 0.3s linear;
      box-shadow:0 0 20px #cccccc;
    }
    .goods-detail-item-top {
      overflow: hidden;
      height: 228px;
      img {
        border-radius: 10px 10px;
        width: 100%;
      }
    }
  }
  /*.goods-detail-item:hover {*/
  /*  border: 1px solid #C0C4CC;*/
  /*  padding: 9px;*/
  /*}*/

  .price {
    color: orangered;
    font-weight: bolder;
    margin: 10px;
  }
  .title {
    font-size: 12px;
    margin-top: 20px;
  }
  .title a:hover {
    color: orangered;
  }
  .operate {
    margin-top: 20px;
    display: flex;
    align-items: center;
    a {
      width: 50%;
      height: 30px;
      line-height: 30px;
      font-size: 14px;
      color: #999999;
      cursor: pointer;
    }
    a:nth-of-type(1) {
      border-right: 1px solid antiquewhite;
    }
  }
  .check {
    transform: rotate(-50deg);
    position: absolute;
    font-size: 40px;
    color: #cccccc;
    /* left: -80px; */
    top: 6px;
    left: -73px;
    opacity: 0.8;
    width: 200px;
    background: #ece3d4;
  }
  .active {
    background: orangered;
    color: white;
  }
</style>
